package com.pgeneral.user.management.service.impl;

import com.pgeneral.user.management.vo.UserSopRoleScopeVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

import com.pgeneral.user.management.entity.UserSopRole;
import com.pgeneral.user.management.dao.UserSoproleMapper;
import com.pgeneral.user.management.service.UserSoproleService;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserSoproleServiceImpl implements UserSoproleService {

    @Resource
    private UserSoproleMapper dao;


    @Override
    public List<UserSopRole> getUserSopRoleAll() {
        List<UserSopRole> userSopRoleAllLists = dao.getUserSopRoleAll();
        //如果查询的角色都为空
        if (userSopRoleAllLists.isEmpty()) {
            return new ArrayList<>();
        }
        return userSopRoleAllLists;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteInfoByRoleId(String roleId) {
        return dao.deleteInfoByRoleId(roleId);
    }

    @Override
    public List<UserSopRoleScopeVO> getInfoByRoleId(String roleId) {
        return dao.getInfoByRoleId(roleId);
    }
}
